<?php

namespace App\ServicesNew;

use App\BO\Distributor\Meta\BindRelationShip;
use App\BO\Distributor\Meta\UserDistributorRate;
use App\Entities\PaymentEntity;
use App\Entities\TransactionRecordEntity;
use App\VO\UserBalance\TransactionSearchInfo;

interface DistributorService
{
    /**
     * 获取用户的绑定关系
     * @param int $userId
     * @return BindRelationShip
     */
    public function getBindRelationShip(int $userId);

    /**
     * 下发分销收益
     * @param int $userId
     * @param PaymentEntity $paymentEntity
     * @return mixed
     */
    public function giveProfit(int $userId, PaymentEntity $paymentEntity);

    /**
     * 下发冻结状态的分销收益
     * @param int $userId
     * @param PaymentEntity $paymentEntity
     * @return
     */
    public function giveFreezeProfit(int $userId, PaymentEntity $paymentEntity);

    /**
     * 给用户添加冻结分销记录
     * @param int $amount
     * @param int $orderId
     * @param UserDistributorRate $userDistributorRate
     * @return void
     */
    public function addFreezeProfitRecord(int $amount, int $orderId, UserDistributorRate $userDistributorRate);

    /**
     * 直接收益
     * @param int $amount
     * @param UserDistributorRate $userDistributorRate
     * @return void
     */
    public function addProfitRecord(int $amount, UserDistributorRate $userDistributorRate);

    /**
     * 确认收益，将冬结的金额转为正常
     * @param PaymentEntity $paymentEntity
     * @return
     */
    public function confirm(PaymentEntity $paymentEntity);

    /**
     * 解冻收益
     * @param TransactionRecordEntity $transactionRecordEntity
     * @return
     */
    public function unfreeze(TransactionRecordEntity $transactionRecordEntity);

    /**
     * 用取消订单，收益回退
     * @param PaymentEntity $paymentEntity
     * @return mixed
     */
    public function refund(PaymentEntity $paymentEntity);

    /**
     * @param TransactionRecordEntity $transactionRecordEntity
     * @return mixed
     */
    public function rollback(TransactionRecordEntity $transactionRecordEntity);

    /**
     * @param TransactionSearchInfo $searchInfo
     * @return TransactionRecordEntity[]
     */
    public function getTransactionRecord(TransactionSearchInfo $searchInfo);

    /**
     * @param TransactionSearchInfo $searchInfo
     * @return int
     */
    public function count(TransactionSearchInfo $searchInfo);
}
